package com.ag.lwc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbEventStatus;
import com.ag.bean.TbLogType;
import com.ag.common.AgException;
import com.ag.common.IDUtil;
import com.ag.common.IIDService;
import com.ag.lwc.dao.MyTbEventStatusDAO;
import com.ag.lwc.dao.MyTbLogTypeDAO;
import com.ag.lwc.service.TbLogTypeService;
@Service("TbLogTypeService")
public class TbLogTypeServiceImpl implements TbLogTypeService {

	@Resource(name="lwcTbLogTypeDAO")	
	private	MyTbLogTypeDAO tbLogTypeDAO;
	@Resource(name="iDServiceImpl")
	private IIDService 	idService;
	private IDUtil idUtil;
	@Override
	public void delete(TbLogType tbLogType) {
		tbLogTypeDAO.delete(tbLogType);

	}

	@Override
	public void delete(String id) {
		tbLogTypeDAO.delete(id);

	}

	@Override
	public List<TbLogType> findAll() {
	
		return tbLogTypeDAO.findAll();
	}

	@Override
	public TbLogType findById(String id) {
		System.out.println("TbLogTypeServiceImpl:  日志类型id："+id);
		return tbLogTypeDAO.findById(id);
		
	}

	@Override
	public void save(TbLogType tbLogType) throws AgException {
		long index=	idUtil.TB_LOGTYPE;
		String id=	idService.findTablePK(Long.valueOf(index));
		System.out.println("***************id="+id+"******************");
	//	tbLogType.setA(IDUtil.PRESERVE);
		tbLogType.setLtId(id);
		tbLogTypeDAO.save(tbLogType);

	}

	@Override
	public void update(TbLogType tbLogType) {
		TbLogType logType=tbLogTypeDAO.findById(tbLogType.getLtId());
		logType.setLtName(tbLogType.getLtName());
		logType.setLtColor(tbLogType.getLtColor());
		tbLogTypeDAO.attachDirty(logType);

	}

	public MyTbLogTypeDAO getTbLogTypeDAO() {
		return tbLogTypeDAO;
	}

	public void setTbLogTypeDAO(MyTbLogTypeDAO tbLogTypeDAO) {
		this.tbLogTypeDAO = tbLogTypeDAO;
	}

	public IIDService getIdService() {
		return idService;
	}

	public void setIdService(IIDService idService) {
		this.idService = idService;
	}

	public IDUtil getIdUtil() {
		return idUtil;
	}

	public void setIdUtil(IDUtil idUtil) {
		this.idUtil = idUtil;
	}

}
